<?php
$paginator->options(array('url' => $this->passedArgs, 'update' => 'content', 'indicator' => 'spinner'));
if(!isset($norace))
    $norace = false;
if(!isset($noteam))
    $noteam = false;
?>

<div class="players">
<h2><?php __('Players');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort('#', 'Player.iNumber');?></th>
	<th><?php echo $paginator->sort(__('Name', true), 'Player.strName');?></th>
	<th><?php echo $paginator->sort(__('Type', true), 'PlayerType.ID');?></th>
	<?php if(!$noteam) { ?>
	<th><?php echo $paginator->sort(__('Team', true), 'Team.ID');?></th>
	<?php } ?>
	<?php if(!$norace) {?>
	<th><?php echo $paginator->sort(__('Race', true), 'Race.ID');?></th>
	<?php } ?>
	<th><?php echo $paginator->sort(__('Mv', true), 'Player.Characteristics_fMovementAllowance');?></th>
	<th><?php echo $paginator->sort(__('St', true), 'Player.Characteristics_fStrength');?></th>
	<th><?php echo $paginator->sort(__('Ag', true),'Player.Characteristics_fAgility');?></th>
	<th><?php echo $paginator->sort(__('Ar', true), 'Player.Characteristics_fArmourValue');?></th>
	<th><?php echo $paginator->sort(__('XP', true), 'Player.iExperience');?></th>
	<th><?php echo $paginator->sort(__('Val', true), 'Player.iValue');?></th>
	<th class="actions"><?php __('Skills');?></th>
	<th><?php echo $paginator->sort(__('Level', true), 'PlayerLevel.ID');?></th>
	<th class="actions"><?php __('State');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($players as $player):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td><?php echo $player['Player']['iNumber']; ?></td>
		<td>
		<?php
		echo $player['Player']['strName'].' ';
		if($player['Player']['bStar'] == 1) {
		   echo $html->image('star_small.jpg', array('alt' => 'Is Star'));
		}
		?>
		</td>
		<td><?php echo $html->link($player['PlayerType']['LocalizedString'][$locale], array('controller' => 'player_types', 'action' => 'view', $player['PlayerType']['ID'])); ?></td>
		<?php if(!$noteam) { ?>
		<td><?php echo $html->link($player['Team']['strName'], array('controller' => 'teams', 'action' => 'view', $player['Team']['ID'])); ?></td>
		<?php } ?>
		<?php if(!$norace) { ?>
		<td><?php echo $html->link($player['Race']['LocalizedString'][$locale], array('controller' => 'races', 'action' => 'view', $player['Race']['ID'])); ?></td>
		<?php } ?>

		<td><?php echo $player['Player']['Characteristics_fMovementAllowance']; ?></td>
		<td><?php echo $player['Player']['Characteristics_fStrength']; ?></td>
		<td><?php echo $player['Player']['Characteristics_fAgility']; ?></td>
		<td><?php echo $player['Player']['Characteristics_fArmourValue']; ?></td>
		<td><?php echo $player['Player']['iExperience']; ?></td>
		<td><?php echo $player['Player']['iValue']; ?></td>
		<td class="p_skills">
			<?php
			$isFirst = true;
			foreach($player['PlayerType']['Skill'] as $skill)
			{
				if ($isFirst === true) {
					$isFirst = false;
				} else {
					echo ', ';
				}?>
				<acronym title="<?php echo $skill['FormattedString'][$locale]?>">
				<?php
				echo $skill['LocalizedString'][$locale];
				?>
				</acronym>
			<?php echo $html->link('^', array('controller' => 'skills', 'action' => 'view', $skill['ID']));
			}

			foreach($player['Skill'] as $skill)
			{
				if ($isFirst === true) {
					$isFirst = false;
				} else {
					echo ', ';
				}?>
				<acronym title="<?php echo $skill['FormattedString'][$locale]?>">
				<?php
				echo $skill['LocalizedString'][$locale];
				?>
				</acronym>
			<?php echo $html->link('^', array('controller' => 'skills', 'action' => 'view', $skill['ID']));
			} ?>
			</td>
		<td><?php echo $html->link($player['PlayerLevel']['LocalizedString'][$locale], array('controller' => 'player_levels', 'action' => 'view', $player['PlayerLevel']['ID'])); ?></td>
		<td><?php
			if($player['Player']['bDead'] == 1) {
			   echo $html->image('dead_small.png', array('alt' => 'Is Dead'));
			}else if($player['Player']['iMatchSuspended'] == 1) {
				echo 'MNG';
			}
			?></td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('controller' => 'players', 'action' => 'view', $player['Player']['ID'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>